import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @author LKQ
 * @date 2021/12/20 17:03
 * @description
 */
public class HashSolution {
    public static void main(String[] args) {
        HashSolution solution = new HashSolution();
        int[] nums = {1, 1, 2, 3, 4, 5, 5, 4};
        System.out.println(Arrays.toString(solution.singleNumber(nums)));
    }

    public int[] singleNumber(int[] nums) {
        Map<Integer, Integer> freq = new HashMap<Integer, Integer>();
        for (int num : nums) {
            freq.put(num, freq.getOrDefault(num, 0) + 1);
        }
        int[] ans = new int[2];
        int index = 0;
        for (Map.Entry<Integer, Integer> entry : freq.entrySet()) {
            if (entry.getValue() == 1) {
                ans[index++] = entry.getKey();
            }
        }
        return ans;
    }

}
